<?php defined('RUN_KATANA') or die('Restricted access'); ?>
<?php 
if(!$_POST)
{ 
	if(is_object($fc->getCurrentForm()))
	{
		if($fc->CurrentForm->getFields())
		{
			foreach($fc->getCurrentForm()->getFields() as $subitem)
			{
				echo '<tr class="items">';
				echo '<td class="first center">'.$subitem->getId().'</td>';
				echo '<td>';
				echo 	'<input type="hidden" name="ff_id[]" value="'.$subitem->getId().'" />';
				echo 	'<div style="display:none;">'.$subitem.'</div>';
				echo 	'<input class="select_list" type="checkbox" name="selected[]" value="'.$subitem->getId().'" /></td>';
				echo '<td><input class="small" name="ff_name[]" type="text" value="'.$subitem->getName().'" maxlength="100" /></td>';
				echo '<td><input class="small" name="ff_label[]" type="text" value="'.$subitem->getLabel().'" maxlength="250" /></td>';
				echo '<td><input class="small" name="ff_info[]" type="text" value="'.$subitem->getInfo().'" maxlength="250" /></td>';
				echo '<td><input class="small" name="ff_class[]" type="text" value="'.$subitem->getClass().'" maxlength="100" /></td>';
				?>
				<td>
					<select name="ff_type[]" class="small">
						<?php 
						echo '<option value="0" '.$txt->getIsSelectedHTML($subitem->getType(true), 0) .'>text</option>';
						echo '<option value="1" '.$txt->getIsSelectedHTML($subitem->getType(true), 1) .'>radio</option>';
						echo '<option value="2" '.$txt->getIsSelectedHTML($subitem->getType(true), 2) .'>checkbox</option>';
						echo '<option value="3" '.$txt->getIsSelectedHTML($subitem->getType(true), 3) .'>select</option>';
						echo '<option value="4" '.$txt->getIsSelectedHTML($subitem->getType(true), 4) .'>textarea</option>';
						echo '<option value="5" '.$txt->getIsSelectedHTML($subitem->getType(true), 5) .'>submit</option>';
						echo '<option value="6" '.$txt->getIsSelectedHTML($subitem->getType(true), 6) .'>File</option>';
						echo '<option value="7" '.$txt->getIsSelectedHTML($subitem->getType(true), 7) .'>Button</option>';
						echo '<option value="10" '.$txt->getIsSelectedHTML($subitem->getType(true), 10) .'>Spacer</option>';
						echo '<option value="11" '.$txt->getIsSelectedHTML($subitem->getType(true), 11) .'>Label</option>';
						echo '<option value="12" '.$txt->getIsSelectedHTML($subitem->getType(true), 12) .'>Info</option>';
						?>
					</select>
					<?php if(($subitem->getType(true) > 2) && ($subitem->getType(true) < 4)): ?>
					<img title="<?php echo ucfirst($txt->getWord('define').' '.$txt->getWord('source')); ?>" class="icon command field_define_src" src="<?php echo SYSICONS_URL; ?>table_16.png" onclick="srcOptions(<?php echo $subitem->getId(); ?>, '<?php echo $subitem->getSrcTable(); ?>', '<?php echo $subitem->getSrcLblSelect(); ?>', '<?php echo $subitem->getSrcValSelect(); ?>', '<?php echo $subitem->getSrcWhere(); ?>', '<?php echo $subitem->getSrcValDef(); ?>');" />
					<?php endif; ?>
					<input type="hidden" id="ff_srcTable_<?php echo $subitem->getId(); ?>" name="ff_srcTable_<?php echo $subitem->getId(); ?>" value="<?php echo $subitem->getSrcTable(); ?>" />
					<input type="hidden" id="ff_srcLblSelect_<?php echo $subitem->getId(); ?>" name="ff_srcLblSelect_<?php echo $subitem->getId(); ?>" value="<?php echo $subitem->getSrcLblSelect(); ?>" />
					<input type="hidden" id="ff_srcValSelect_<?php echo $subitem->getId(); ?>" name="ff_srcValSelect_<?php echo $subitem->getId(); ?>" value="<?php echo $subitem->getSrcValSelect(); ?>" />
					<input type="hidden" id="ff_srcWhere_<?php echo $subitem->getId(); ?>" name="ff_srcWhere_<?php echo $subitem->getId(); ?>" value="<?php echo $subitem->getSrcWhere(); ?>" />
					<input type="hidden" id="ff_srcValDef_<?php echo $subitem->getId(); ?>" name="ff_srcValDef_<?php echo $subitem->getId(); ?>" value="<?php echo $subitem->getSrcValDef(); ?>" />
				</td>
				<td>
					<select name="ff_validType[]" class="small-m" onchange="submit();">
						<?php 
						echo '<option value="" '.$txt->getIsSelectedHTML($subitem->getValidType(), '').'>'.ucfirst($txt->getWord('none')).'</option>';
						echo '<option value="text" '.$txt->getIsSelectedHTML($subitem->getValidType(), 'text').'>'.ucfirst('text').'</option>';
						echo '<option value="numeric" '.$txt->getIsSelectedHTML($subitem->getValidType(), 'numeric').'>'.ucfirst('numeric').'</option>';
						echo '<option value="anum" '.$txt->getIsSelectedHTML($subitem->getValidType(), 'anum').'>'.ucfirst($txt->getWord('valid_chars_anum')).'</option>';
						echo '<option value="alpha" '.$txt->getIsSelectedHTML($subitem->getValidType(), 'alpha').'>'.ucfirst($txt->getWord('valid_chars_alpha')).'</option>';
						echo '<option value="email" '.$txt->getIsSelectedHTML($subitem->getValidType(), 'email').'>'.ucfirst($txt->getWord('e-mail')).'</option>';
						echo '<option value="yes-no" '.$txt->getIsSelectedHTML($subitem->getValidType(), 'yes-no').'>'.ucfirst($txt->getWord('yes')).' / '.ucfirst($txt->getWord('no')).' - (1/0)</option>';
						echo '<option value="yes-no-na" '.$txt->getIsSelectedHTML($subitem->getValidType(), 'yes-no-na').'>'.ucfirst($txt->getWord('yes')).' / '.ucfirst($txt->getWord('no')).' - '.ucfirst($txt->getWord('unknown')).' - (1/0)</option>';
						?>
					</select>
				</td>
				<td class="center">
					<input class="xsmall" type="text" name="ff_value[]" value="<?php echo $subitem->getValue(); ?>" maxlength="250" />
				</td>
				<td class="center">
					<input type="checkbox" name="ff_visible_<?php echo $subitem->getId(); ?>" value="1" <?php echo $txt->getIsCheckedHTML($subitem->getVisible(), 1); ?> />
				</td>
				<td class="center">
					<input type="checkbox" name="ff_req_<?php echo $subitem->getId(); ?>" value="1" <?php echo $txt->getIsCheckedHTML($subitem->getReq(), 1); ?> />
				</td>
				<td class="center">
					<input class="max_4 xsmall numeric int" type="text" name="ff_minLen[]" value="<?php echo $subitem->getMinLen(); ?>" maxlength="4" />
				</td>
				<td class="center">
					<input class="max_4 xsmall numeric int" type="text" name="ff_maxLen[]" value="<?php echo $subitem->getMaxLen(); ?>" maxlength="4" />
				</td>
				<td class="center">
					<input type="checkbox" name="ff_nospace_<?php echo $subitem->getId(); ?>" value="1" <?php echo $txt->getIsCheckedHTML($subitem->getNospace(), 1); ?> />
				</td>
				<?php 
				echo '<td>';
				echo 	'<select class="small" name="ff_compare[]" >';
				echo 		'<option value="" '.$txt->getIsSelectedHTML($subitem->getCompare(), '').'>'.ucfirst($txt->getWord('none')).'</option>';
							if($fc->getCurrentForm()->getFields())
							{
								foreach($fc->getCurrentForm()->getFields() as $field)
								{ echo '<option value="'.$field->getName().'" '.$txt->getIsSelectedHTML($field->getName(), $subitem->getCompare()).'>'.$field->getName().'</option>'; }
							}
				echo 	'</select>';
				echo '</td>';
				?>
				<td class="center">
                    <?php echo $commander->getSortButtonAjax('up', $subitem->getId()); ?>
                    <?php echo $commander->getSortButtonAjax('down', $subitem->getId()); ?>
                </td>
				<td>
					<?php echo $commander->getActivationFieldsObjectAjax($subitem); ?>
					<input type="hidden" name="ff_active[]" value="<?php echo $subitem->getActive(); ?>" />
				</td>
				<td class="last center">
				<img title="<?php echo ucfirst($txt->getWord('delete').' '.$txt->getWord('field')); ?>" class="icon command field_delete" src="<?php echo SYSICONS_URL; ?>delete_16.gif" onclick="deleteDialog(<?php echo $subitem->getId(); ?>);" />
				</td>
				<?php
				echo '</tr>';
			}
		}
		else
		{
			echo '<tr class="items">';
			echo '<td class="first center">0</td>';
			echo '<td class="center">';
			echo 	'<input class="select_list" type="checkbox" name="selected[]" value="0" /></td>';
			echo '<td>'.ucfirst($txt->getWord('empty')).'</td>';
			?>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td class="last center">&nbsp;</td>
			<?php
			echo '</tr>';
		}
	}
}
?>